package com.jwd.config

import com.jwd.PzxApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.*
import org.springframework.web.servlet.HandlerInterceptor


/**
 * Created by udi on 2017.3.4.
 */
@Configuration
class MyWebMvcConfig : WebMvcConfigurerAdapter() {

    companion object {
        /**
         * 登录session key
         */
        @JvmStatic val SESSION_KEY = "user"
    }

//    @Bean
//    fun getHttpContext(): HandlerInterceptor {
//        return MyFilter()
//    }

    override fun addInterceptors(registry: InterceptorRegistry?) {
        registry!!.addInterceptor(MyFilter())
                .addPathPatterns("/**");

        registry!!.addInterceptor(MySessionFilter())
                .addPathPatterns("/**")
                .excludePathPatterns("/")
                .excludePathPatterns("/home**")
                .excludePathPatterns("/error")
                .excludePathPatterns("/login");
    }
}